package com.hj.ct.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;

import com.hj.ct.R;
import com.hj.ct.logic.LogicActions;

public class MainActivity2 extends BaseActivity implements OnClickListener {

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main_2);
		findView(R.id.main_radio).setOnClickListener(this);
		findView(R.id.tuan_radio).setOnClickListener(this);
		findView(R.id.my_radio).setOnClickListener(this);
		findView(R.id.logout_radio).setOnClickListener(this);
	}

	public void onClick(View v) {
		if (v.getId() == R.id.main_radio) {
			startActivity(new Intent(this, MapActivity.class));
		} else if (v.getId() == R.id.tuan_radio) {
			startActivity(new Intent(this, BarChartActivity.class));
		} else if (v.getId() == R.id.my_radio) {
			startActivity(new Intent(this, SettingActivity.class));
		} else if (v.getId() == R.id.logout_radio) {
			showLogoutDialog();
		}
	}

	public void handlerUI(int aciton, int code, Object... obj) {
		dismissDialog();
		if (aciton == LogicActions.LOGOUT_SUCCESS || aciton == LogicActions.LOGOUT_ERROR) {
			gotoLogin();
		}
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		// TODO Auto-generated method stub
		// 按下HOME键或返回键
		if (keyCode == KeyEvent.KEYCODE_HOME || keyCode == KeyEvent.KEYCODE_BACK) {
			moveTaskToBack(true);
			return true;
		}
		return super.onKeyDown(keyCode, event);
	}
}
